package com.learn.util;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class TempUtil {

    public static void main(String[] args) {
        System.out.println(TempUtil.toDate(1655384916000L));
    }

    public static String toDate(Long ts) {

        return new SimpleDateFormat("yyyy-MM-dd").format(ts);


    }

    public static String toDateV2(Long ts) {

        return new SimpleDateFormat("yyyyMMdd").format(ts);

    }


    public static <T> List<T> toList(Iterable<T> it) {

        List<T> list = new ArrayList<>();
        it.forEach(list::add);
        return list;
    }


    public static void printTable(String[] strings) {
        for (int i = 0; i < strings.length; i++) {
            System.out.println(strings[i]);
        }
    }

    public static String toDateTime(Long ts) {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(ts);
    }

    public static boolean isLargeThan(String cur, String last) {
        //2022-08-20 06:23:01.933Z
        // 把z干掉, 然后直接比字符串
        cur = cur.replaceAll("Z", "");
        last = last.replaceAll("Z", "");
        // compareTo: one 大于tow的时候返回时正的
        return  cur.compareTo(last) > 0;

    }
}
